<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="root"></div>
<script src="../../javascript/react.development.js"></script>
<script src="../../javascript/react-dom.development.js"></script>
<script src="../../javascript/babel.min.js"></script>
<script type="text/babel">
    class App extends React.Component {
        constructor(props, context) {
            super(props, context)
            this.state = {count: 1}
        }

        render() {
            return (
                <div className="app">
                    <button onClick={() => {
                        this.addCount()
                    }}>点击{this.state.count}</button>
                </div>
            );
        }

        addCount() {
            this.setState({count: this.state.count += 1}, () => {
                console.log(this.state.count) // setState函数的第二个参数里面能拿到更新后的值
            })
        }
    }
    ReactDOM.render(<App></App>, document.querySelector("#root"))
</script>
</body>
</html>